import entity.Student;

import java.util.List;
import java.util.Scanner;

public class Setup {
    private static final GSonStore store = new GSonStore();
    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) throws Exception {
        List<Student> students = store.read();

        while(true){
            System.out.println("您可以进行以下操作：");
            System.out.println("1. 添加一个新的学生信息");
            System.out.println("2. 修改一个已有的学生信息");
            System.out.println("3. 删除一个已有的学生信息");
            System.out.println("4. 列出全部学生信息");
            System.out.println("5. 撤销上一次操作");
            System.out.println("6. 退出程序");
            System.out.print("您的选择是：");
            System.out.println();

            String line = scanner.nextLine();
            int choice;
            try{
                 choice = Integer.parseInt(line);
            }catch(Exception e){
                System.err.println("请输入一个数字！");
                continue;
            }

            if(choice < 1 || choice > 6){
                System.err.println("请输入一个1-6之间的数字！");
                continue;
            }

            if(choice == 6){
                break;
            }

            CommandContorller.execute(choice,students);

            Thread.sleep(200);
            System.out.println();
        }

        store.write(students);
    }
}
